package com.xindaoapp.happypet.utils;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.xindaoapp.happypet.R;

/**
 * 通知管理器
 * 
 * @author chenghao
 * 
 */
public class NotifyManager {
    // public static final int sPOSTSUCCESS = 0;
    // public static final int sPOSTFAILED = 1;

    public static final int sPOST = 0;

    public static void showUploadPostNotify(Context context, String tickerText, String title,
            String content, int id, Intent intent) {
        NotificationManager nm =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification n = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis());
        n.flags = Notification.FLAG_AUTO_CANCEL;
        // Intent i = new Intent(context, NotificationShow.class);
        // i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        // PendingIntent
        PendingIntent contentIntent =
                PendingIntent.getActivity(context, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        n.setLatestEventInfo(context, title, content, contentIntent);
        nm.notify(id, n);
    }

    public static void remove(Context context, int codeId) {
        NotificationManager nm =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(codeId);
    }

}
